# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=spike-fuzzer
pkgver=2.9
pkgrel=1
groups=('blackarch' 'blackarch-fuzzer')
pkgdesc="IMMUNITYsec's fuzzer creation kit in C."
arch=('x86_64' 'aarch64')
url='http://www.immunitysec.com/resources-freesoftware.shtml'
license=('GPL2')
depends=('gcc' 'automake' 'openssl' 'autoconf')
optdepends=('python2: needed to run SPIKE_Console.py python GUI'
            'wxpython: needed to run SPIKE_Console.py python GUI')
source=("http://www.immunitysec.com/downloads/SPIKE$pkgver.tgz")
sha512sums=('733d788dfb0558bb1fa8e083e7dca095f188cbc65d7bb94349dd487a84a627937b2dea5fb32d16272deea8d464085b8c6efc374ffd6806710106358d873439e2')

prepare() {
  cd SPIKE/SPIKE/src

  sed -i 's|/usr/bin/python|/usr/bin/python2|g' SPIKE_Console.py
}

build() {
  cd SPIKE/SPIKE/src

  #aclocal
  #automake --add-missing
  #autoconf

  ./configure --prefix=/usr

  make
}

package() {
  cd SPIKE/SPIKE/src

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/lib"
  install -dm 755 "$pkgdir/usr/include/$pkgname"
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname"

  # Install binaries.
  # The package doesn't provide a decent method of installation.
  for bin in citrix closed_source_web_server_fuzz dceoversmb dltest do_post \
    generic_chunked generic_listen_tcp generic_send_tcp generic_send_udp \
    generic_web_server_fuzz generic_web_server_fuzz2 gopherd halflife \
    line_send_tcp msrpcfuzz msrpcfuzz_udp ntlm2 ntlm_brute pmspike post_fuzz \
    post_spike quake quakeserver sendmsrpc ss_spike statd_spike sunrpcfuzz \
    webfuzz x11_spike ; do
    install -m 755 "$bin" "$pkgdir/usr/bin/$pkgname-${bin/_/-}"
  done

  install -m 755 *.so "$pkgdir/usr/lib/"

  cd "$srcdir/SPIKE/SPIKE"

  install -m 644 include/* "$pkgdir/usr/include/$pkgname"
  install -m 644 *.txt documentation/* \
          "$pkgdir/usr/share/doc/$pkgname"

  cp --no-preserve=ownership -R dcedump data encrypted \
    "$pkgdir/usr/share/$pkgname/"
}

